﻿using System.Collections.Generic;

namespace MobySharp.Actions
{
    public class PostMedia : BaseAction, IAction
    {
        private List<string> _hashtag = new List<string>();
        private LatLong _location = new LatLong();
        private List<string> _tags = new List<string>();

        public PostMedia(string username, string password, string img)
        {
            Username = username;
            Password = password;
            Img = img;

            RequestType = HTTPRequestType.MultipartPost;
            Action = APICall.postMedia;
        }

        [PostDataInstruction("i", true)]
        public string Img { get; set; }

        [PostDataInstruction("u", true, 32)]
        public string Username { get; set; }

        [PostDataInstruction("p", true, 32)]
        public string Password { get; set; }

        [PostDataInstruction("t", false, 200)]
        public string Title { get; set; }

        [PostDataInstruction("d", false, 10000)]
        public string Description { get; set; }

        [PostDataInstruction("tags", false, 100)]
        public List<string> Tags
        {
            get { return _tags; }
            set { _tags = value; }
        }

        [PostDataInstruction("ht", false, 32)]
        public List<string> Hashtag
        {
            get { return _hashtag; }
            set { _hashtag = value; }
        }

        [PostDataInstruction("latlong", false, 32)]
        public LatLong Location
        {
            get { return _location; }
            set { _location = value; }
        }

        #region Nested type: LatLong

        public class LatLong
        {
            public string Latitude { get; set; }
            public string Longitude { get; set; }

            public override string ToString()
            {
                if (string.IsNullOrEmpty(Latitude) || string.IsNullOrEmpty(Longitude))
                    return string.Empty;

                return string.Format("{0},{1}", Latitude, Longitude);
            }
        }

        #endregion

        //TODO: Services
        /*
        Field name: s
        Max. length: 64	Service(s)	
        Example: twitter,flickr,tumblr
                 or: none,+twitter
                 or: all,-twitter
         */


        /*

        //Taken on (ISO 8601 date)	2009-10-27T15:19:21+01:00 --> DateTime.ToString("s")
        private DateTime _takenOn;
        [PostDataInstruction("taken_on", false, 64)]
        public string TakenOn
        {
            get { return _takenOn.ToString("s"); }
            set { _takenOn = DateTime.Parse(value); }
        } 
        */
    }
}